/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interface.CajaPrincipal;

import Interface.Acceso;
import Interface.Articulos.ABM_Artículos;
import Interface.GUIM;
import LN.Articulos.Articulo;
import LN.Articulos.Articulo_Estatico;
import LN.Varios.Conceptos;
import LN.Varios.Hosteria;
import LN.Varios.Lote;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.util.List;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.Timer;

/**
 *
 * @author Lukas
 */
public class Ingreso_Egreso extends javax.swing.JPanel {

    private Hosteria unaHosteria;
    private Lote unLote;
    private boolean pruebaLogica = false;

    public Ingreso_Egreso(Hosteria unaHosteria, Lote unLote) {
        this.unaHosteria = unaHosteria;
        this.unLote = unLote;
        initComponents();

        cbx_articulosItemStateChanged(null);
        dp_fecha_pago.setDate(new Date());
        dp_fecha_cobro.setDate(new Date());
        timer.start();


        cbx_articulosItemStateChanged(null);
        cargarCombo_Articulos();
        carcarCombo_Conceptos();

    }

    private void carcarCombo_Conceptos() {
        List<Conceptos> conceptos = unaHosteria.getCajaPrincipal().getConceptos();
        for (Conceptos unConcepto : conceptos) {
            if (unConcepto.getTipo().equals("Entrada")) {
                cbx_conceptoEntrada.addItem(unConcepto);
            } else {
                cbx_conceptoSalida.addItem(unConcepto);
            }

        }
//        if (cbx_conceptoEntrada.getItemCount() > 0) {
//            cbx_conceptoEntrada.setSelectedIndex(0);
//            Conceptos unConcepto = (Conceptos) cbx_conceptoEntrada.getSelectedItem();
//        }
    }

    private void cargarCombo_Articulos() {
        List<Articulo> articulos = unaHosteria.getArticulos();
        if (!articulos.isEmpty()) {
            cbx_articulos.removeAllItems();
            for (Articulo unArticulo : articulos) {
                cbx_articulos.addItem(unArticulo);
            }
        }
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pestañas = new javax.swing.JTabbedPane();
        pnl_cobrar = new javax.swing.JPanel();
        dp_fecha_cobro = new org.jdesktop.swingx.JXDatePicker();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txt_hora_cobro = new javax.swing.JTextField();
        panelCurves1 = new org.edisoncor.gui.panel.PanelCurves();
        btn_aceptar = new javax.swing.JButton();
        btn_cancelar = new javax.swing.JButton();
        txt_monto_cobro = new org.jdesktop.swingx.JXTextField();
        jLabel5 = new javax.swing.JLabel();
        clockFace2 = new org.edisoncor.gui.varios.ClockFace();
        cbx_conceptoEntrada = new com.jidesoft.swing.AutoCompletionComboBox();
        btn_agregarConcepto_Ingreso = new org.edisoncor.gui.button.ButtonCircle();
        pnl_pagar = new javax.swing.JPanel();
        jTextField2 = new javax.swing.JTextField();
        txt_monto_pago = new org.jdesktop.swingx.JXTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        dp_fecha_pago = new org.jdesktop.swingx.JXDatePicker();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txt_hora_pago = new javax.swing.JTextField();
        panelCurves2 = new org.edisoncor.gui.panel.PanelCurves();
        btn_aceptar1 = new javax.swing.JButton();
        btn_cancelar1 = new javax.swing.JButton();
        cbx_articulos = new com.jidesoft.swing.AutoCompletionComboBox();
        clockFace1 = new org.edisoncor.gui.varios.ClockFace();
        btn_agregarArticulo = new org.edisoncor.gui.button.ButtonCircle();
        cbx_conceptoSalida = new com.jidesoft.swing.AutoCompletionComboBox();
        jLabel10 = new javax.swing.JLabel();
        btn_agregarConcepto_Egreso = new org.edisoncor.gui.button.ButtonCircle();

        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS));

        pestañas.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        pestañas.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N

        jLabel2.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel2.setText("Fecha");

        jLabel3.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel3.setText("Concepto:");

        jTextField1.setEditable(false);
        jTextField1.setFont(new java.awt.Font("Copperplate Gothic Light", 1, 12)); // NOI18N
        jTextField1.setText("Ingrese la información correspondiente al nuevo movimiento");
        jTextField1.setBackground(new java.awt.Color(153, 153, 153));
        jTextField1.setFocusable(false);
        jTextField1.setForeground(new java.awt.Color(255, 255, 255));

        jLabel4.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel4.setText("Hora");

        btn_aceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/down.png"))); // NOI18N
        btn_aceptar.setText("Aceptar");
        btn_aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_aceptarActionPerformed(evt);
            }
        });

        btn_cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Close.png"))); // NOI18N
        btn_cancelar.setText("Cancelar");
        btn_cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelCurves1Layout = new javax.swing.GroupLayout(panelCurves1);
        panelCurves1.setLayout(panelCurves1Layout);
        panelCurves1Layout.setHorizontalGroup(
            panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCurves1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btn_aceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_cancelar)
                .addContainerGap())
        );
        panelCurves1Layout.setVerticalGroup(
            panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCurves1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btn_aceptar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_cancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        txt_monto_cobro.setBackground(new java.awt.Color(102, 255, 255));
        txt_monto_cobro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_monto_cobroKeyTyped(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel5.setText("Importe:");

        javax.swing.GroupLayout clockFace2Layout = new javax.swing.GroupLayout(clockFace2);
        clockFace2.setLayout(clockFace2Layout);
        clockFace2Layout.setHorizontalGroup(
            clockFace2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 44, Short.MAX_VALUE)
        );
        clockFace2Layout.setVerticalGroup(
            clockFace2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 43, Short.MAX_VALUE)
        );

        cbx_conceptoEntrada.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbx_conceptoEntradaItemStateChanged(evt);
            }
        });

        btn_agregarConcepto_Ingreso.setText("buttonCircle1");
        btn_agregarConcepto_Ingreso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_agregarConcepto_IngresoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnl_cobrarLayout = new javax.swing.GroupLayout(pnl_cobrar);
        pnl_cobrar.setLayout(pnl_cobrarLayout);
        pnl_cobrarLayout.setHorizontalGroup(
            pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelCurves1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
            .addGroup(pnl_cobrarLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnl_cobrarLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbx_conceptoEntrada, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnl_cobrarLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dp_fecha_cobro, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(38, 38, 38)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txt_hora_cobro, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(clockFace2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_agregarConcepto_Ingreso, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addGroup(pnl_cobrarLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txt_monto_cobro, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pnl_cobrarLayout.setVerticalGroup(
            pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnl_cobrarLayout.createSequentialGroup()
                .addGroup(pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnl_cobrarLayout.createSequentialGroup()
                        .addGroup(pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnl_cobrarLayout.createSequentialGroup()
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(dp_fecha_cobro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel4)
                                    .addComponent(txt_hora_cobro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(15, 15, 15))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnl_cobrarLayout.createSequentialGroup()
                                .addComponent(clockFace2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(cbx_conceptoEntrada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btn_agregarConcepto_Ingreso, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnl_cobrarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txt_monto_cobro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addComponent(panelCurves1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pestañas.addTab("Cobrar", new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Sign-Down.png")), pnl_cobrar); // NOI18N

        jTextField2.setEditable(false);
        jTextField2.setBackground(new java.awt.Color(153, 153, 153));
        jTextField2.setFont(new java.awt.Font("Copperplate Gothic Light", 1, 12)); // NOI18N
        jTextField2.setForeground(new java.awt.Color(255, 255, 255));
        jTextField2.setText("Ingrese la información correspondiente al nuevo movimiento");
        jTextField2.setFocusable(false);

        txt_monto_pago.setBackground(new java.awt.Color(255, 102, 102));
        txt_monto_pago.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_monto_pagoKeyTyped(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel6.setText("Importe:");

        jLabel7.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel7.setText("Concepto:");

        jLabel8.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel8.setText("Fecha");

        jLabel9.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel9.setText("Hora");

        btn_aceptar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/down.png"))); // NOI18N
        btn_aceptar1.setText("Aceptar");
        btn_aceptar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_aceptar1ActionPerformed(evt);
            }
        });

        btn_cancelar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Close.png"))); // NOI18N
        btn_cancelar1.setText("Cancelar");
        btn_cancelar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cancelar1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelCurves2Layout = new javax.swing.GroupLayout(panelCurves2);
        panelCurves2.setLayout(panelCurves2Layout);
        panelCurves2Layout.setHorizontalGroup(
            panelCurves2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCurves2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btn_aceptar1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_cancelar1)
                .addContainerGap())
        );
        panelCurves2Layout.setVerticalGroup(
            panelCurves2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCurves2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelCurves2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btn_aceptar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_cancelar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        cbx_articulos.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbx_articulosItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout clockFace1Layout = new javax.swing.GroupLayout(clockFace1);
        clockFace1.setLayout(clockFace1Layout);
        clockFace1Layout.setHorizontalGroup(
            clockFace1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 44, Short.MAX_VALUE)
        );
        clockFace1Layout.setVerticalGroup(
            clockFace1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 43, Short.MAX_VALUE)
        );

        btn_agregarArticulo.setText("buttonCircle1");
        btn_agregarArticulo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_agregarArticuloActionPerformed(evt);
            }
        });

        cbx_conceptoSalida.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbx_conceptoSalidaItemStateChanged(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Bookman Old Style", 0, 18)); // NOI18N
        jLabel10.setText("Artículo relacionado:");

        btn_agregarConcepto_Egreso.setText("buttonCircle1");
        btn_agregarConcepto_Egreso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_agregarConcepto_EgresoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnl_pagarLayout = new javax.swing.GroupLayout(pnl_pagar);
        pnl_pagar.setLayout(pnl_pagarLayout);
        pnl_pagarLayout.setHorizontalGroup(
            pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
            .addGroup(pnl_pagarLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnl_pagarLayout.createSequentialGroup()
                        .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(pnl_pagarLayout.createSequentialGroup()
                                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbx_articulos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnl_pagarLayout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbx_conceptoSalida, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE))
                            .addGroup(pnl_pagarLayout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(dp_fecha_pago, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(31, 31, 31)
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txt_hora_pago, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(clockFace1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btn_agregarConcepto_Egreso, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btn_agregarArticulo, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(pnl_pagarLayout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txt_monto_pago, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addComponent(panelCurves2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        pnl_pagarLayout.setVerticalGroup(
            pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnl_pagarLayout.createSequentialGroup()
                .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnl_pagarLayout.createSequentialGroup()
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnl_pagarLayout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(dp_fecha_pago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel9)
                                    .addComponent(txt_hora_pago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(cbx_conceptoSalida, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(pnl_pagarLayout.createSequentialGroup()
                                .addComponent(clockFace1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btn_agregarConcepto_Egreso, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbx_articulos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10)))
                    .addGroup(pnl_pagarLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btn_agregarArticulo, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(13, 13, 13)
                .addGroup(pnl_pagarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txt_monto_pago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, Short.MAX_VALUE)
                .addComponent(panelCurves2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pestañas.addTab("Pagar", new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Sign-up.png")), pnl_pagar); // NOI18N

        add(pestañas);
    }// </editor-fold>//GEN-END:initComponents

    private void cbx_articulosItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbx_articulosItemStateChanged

        Articulo unArticulo = (Articulo) cbx_articulos.getSelectedItem();
        if (unArticulo instanceof Articulo_Estatico) {
            txt_monto_pago.setText(((Articulo_Estatico) unArticulo).getPrecio().toString());
            txt_monto_pago.setEditable(false);
        } else {
            txt_monto_pago.setText("");
            txt_monto_pago.setEditable(true);
        }

    }//GEN-LAST:event_cbx_articulosItemStateChanged

    private void btn_aceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_aceptarActionPerformed
        Conceptos unConcepto = (Conceptos) cbx_conceptoEntrada.getSelectedItem();
        Date unDia = dp_fecha_cobro.getDate();
        double importe = Double.valueOf(txt_monto_cobro.getText());
        String unaHora = txt_hora_cobro.getText();
        String tipo = "Ingreso";
        double entrada = Double.valueOf(txt_monto_cobro.getText());
        double salida = 0.00;

        if (!unLote.isCerrado()) {
            unLote.altaMovimiento(unDia, unaHora, importe, tipo, unConcepto);
            unaHosteria.crearAuditoria("ADD", "Agregó un movimiento de Ingreso a caja por $" + txt_monto_cobro.getText(), Acceso.getUsuario(), GUIM.getHoraActual());

            SwingUtilities.getWindowAncestor(this).dispose();
        } else {
            JOptionPane.showMessageDialog(this, "El lote al que quiere asignar el movimiento ya fue cerrado");
        }

    }//GEN-LAST:event_btn_aceptarActionPerformed

    private void btn_aceptar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_aceptar1ActionPerformed
        Conceptos unConcepto = (Conceptos) cbx_conceptoSalida.getSelectedItem();
        if (unConcepto.getDetalle().equals("Compra de Insumos")) {
            Articulo unArticulo = (Articulo) cbx_articulos.getSelectedItem();
            unConcepto.setDetalle("Compra de " + unArticulo.getNombre() + " x " + unArticulo.getCuantificacion() + " " + unArticulo.getUnidad());
        }
        Date unDia = dp_fecha_pago.getDate();
        Double importe = Double.valueOf(txt_monto_pago.getText());
        String unaHora = txt_hora_pago.getText();
        String tipo = "Egreso";

        if (!unLote.isCerrado()) {
            unLote.altaMovimiento(unDia, unaHora, importe, tipo, unConcepto);
            unaHosteria.crearAuditoria("ADD", "Agregó un movimiento de Egreso a caja por $" + txt_monto_pago.getText(), Acceso.getUsuario(), GUIM.getHoraActual());
            SwingUtilities.getWindowAncestor(this).dispose();
        } else {
            JOptionPane.showMessageDialog(this, "El lote al que quiere asignar el movimiento ya fue cerrado");
        }

    }//GEN-LAST:event_btn_aceptar1ActionPerformed

    private void btn_cancelar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cancelar1ActionPerformed
        SwingUtilities.getWindowAncestor(this).dispose();
    }//GEN-LAST:event_btn_cancelar1ActionPerformed

    private void btn_cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cancelarActionPerformed
        SwingUtilities.getWindowAncestor(this).dispose();
    }//GEN-LAST:event_btn_cancelarActionPerformed

    private void btn_agregarArticuloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_agregarArticuloActionPerformed
        JDialog frame;
        if (SwingUtilities.getWindowAncestor(this) instanceof JDialog) {
            frame = new JDialog((JDialog) SwingUtilities.getWindowAncestor(this), true);
        } else {
            frame = new JDialog((JFrame) SwingUtilities.getWindowAncestor(this), true);
        }

        ABM_Artículos gestorPais = new ABM_Artículos(unaHosteria);
        frame.getContentPane().removeAll();
        frame.getContentPane().add(gestorPais);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.show();
        cbx_articulos.removeAllItems();
        for (Articulo unArticulo : unaHosteria.getArticulos()) {
            cbx_articulos.addItem(unArticulo);
        }
    }//GEN-LAST:event_btn_agregarArticuloActionPerformed

    private void btn_agregarConcepto_IngresoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_agregarConcepto_IngresoActionPerformed
        abrir_Carga_de_Conceptos();
    }//GEN-LAST:event_btn_agregarConcepto_IngresoActionPerformed

    private void btn_agregarConcepto_EgresoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_agregarConcepto_EgresoActionPerformed
        abrir_Carga_de_Conceptos();
    }//GEN-LAST:event_btn_agregarConcepto_EgresoActionPerformed

    private void cbx_conceptoEntradaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbx_conceptoEntradaItemStateChanged
        if (pruebaLogica && cbx_conceptoEntrada.getSelectedIndex() != -1) {
            unConceptos = (Conceptos) cbx_conceptoEntrada.getSelectedItem();
//            cargarTabla();
        }
    }//GEN-LAST:event_cbx_conceptoEntradaItemStateChanged

    private void cbx_conceptoSalidaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbx_conceptoSalidaItemStateChanged
        String unConcepto = (String) cbx_conceptoSalida.getSelectedItem().toString();
        if (unConcepto.equals("Compra de Insumos")) {
            cbx_articulos.setEnabled(true);
            btn_agregarArticulo.setEnabled(true);
        } else {
            btn_agregarArticulo.setEnabled(false);
            cbx_articulos.setEnabled(false);
        }
    }//GEN-LAST:event_cbx_conceptoSalidaItemStateChanged

    private void txt_monto_cobroKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_monto_cobroKeyTyped
        if (!GUIM.esEntero(evt.getKeyChar())) {
            evt.consume();
        }
    }//GEN-LAST:event_txt_monto_cobroKeyTyped

    private void txt_monto_pagoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_monto_pagoKeyTyped
        if (!GUIM.esEntero(evt.getKeyChar())) {
            evt.consume();
        }
    }//GEN-LAST:event_txt_monto_pagoKeyTyped
    private Timer timer = new Timer(1000, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            txt_hora_pago.setText(GUIM.getHoraActual());
            txt_hora_cobro.setText(GUIM.getHoraActual());

        }
    });
    private Conceptos unConceptos = null;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_aceptar;
    private javax.swing.JButton btn_aceptar1;
    private org.edisoncor.gui.button.ButtonCircle btn_agregarArticulo;
    private org.edisoncor.gui.button.ButtonCircle btn_agregarConcepto_Egreso;
    private org.edisoncor.gui.button.ButtonCircle btn_agregarConcepto_Ingreso;
    private javax.swing.JButton btn_cancelar;
    private javax.swing.JButton btn_cancelar1;
    private com.jidesoft.swing.AutoCompletionComboBox cbx_articulos;
    private com.jidesoft.swing.AutoCompletionComboBox cbx_conceptoEntrada;
    private com.jidesoft.swing.AutoCompletionComboBox cbx_conceptoSalida;
    private org.edisoncor.gui.varios.ClockFace clockFace1;
    private org.edisoncor.gui.varios.ClockFace clockFace2;
    private org.jdesktop.swingx.JXDatePicker dp_fecha_cobro;
    private org.jdesktop.swingx.JXDatePicker dp_fecha_pago;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private org.edisoncor.gui.panel.PanelCurves panelCurves1;
    private org.edisoncor.gui.panel.PanelCurves panelCurves2;
    private javax.swing.JTabbedPane pestañas;
    private javax.swing.JPanel pnl_cobrar;
    private javax.swing.JPanel pnl_pagar;
    private javax.swing.JTextField txt_hora_cobro;
    private javax.swing.JTextField txt_hora_pago;
    private org.jdesktop.swingx.JXTextField txt_monto_cobro;
    private org.jdesktop.swingx.JXTextField txt_monto_pago;
    // End of variables declaration//GEN-END:variables

    private void abrir_Carga_de_Conceptos() {
        JDialog frame;
        if (SwingUtilities.getWindowAncestor(this) instanceof JDialog) {
            frame = new JDialog((JDialog) SwingUtilities.getWindowAncestor(this), true);
        } else {
            frame = new JDialog((JFrame) SwingUtilities.getWindowAncestor(this), true);
        }

        ABM_Conceptos_de_Movimientos gestoronceptos = new ABM_Conceptos_de_Movimientos(unaHosteria);
        frame.getContentPane().removeAll();
        frame.getContentPane().add(gestoronceptos);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.show();
        cbx_articulos.removeAllItems();
        carcarCombo_Conceptos();
    }
}
